package com.erlinyou.im.service.chat.impl;


import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.erlinyou.base.service.BaseServiceImpl;
import com.erlinyou.im.dao.repository.chat.ChatSessionRepository;
import com.erlinyou.im.model.chat.ChatSessionKey;
import com.erlinyou.im.model.chat.ChatSession;
import com.erlinyou.im.service.chat.IChatSessionService;

/**
 *
 */
@Service
public class ChatSessionServiceImpl extends BaseServiceImpl<ChatSession, ChatSessionKey> implements IChatSessionService {
	
	private ChatSessionRepository repository;
	@Resource
	public void setBaseService(ChatSessionRepository repository) {
		this.repository = repository;
		this.baseRepository = repository;
	}
	@Override
	public List<ChatSession> findByUserid(Long userid) {
		return repository.findByUseridOrderByUptimeDesc(userid);
	}
	@Override
	public int deleteByUseridAndRidAndCtype(Long userid, Long rid, Integer ctype) {
		return repository.deleteByUseridAndRidAndCtype(userid, rid, ctype);
	}
	@Override
	public void updateChatSession(List<ChatSession> chatSession) {
		for (ChatSession chatSession2 : chatSession) {
			repository.updateChatSession(chatSession2);
		}
	}
}
